package com.zhb.controller;

import com.zhb.beans.User;
import com.zhb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: atcrowdfunding-web
 * @description:
 * @author: rainboz
 * @create: 2019-09-19 10:29
 **/
@Controller
@RequestMapping("/test")
public class TestController {

    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("/queryAll")
    public Object queryAll(){
       List<User> userList =  userService.queryAll();
       //验证AOP: userService为代理对象
        System.out.println(userService.getClass().getName());
       return userList;
    }
    @RequestMapping("/index")
    public String test() {
        return "index";
    }

    @ResponseBody
    @RequestMapping("/json")
    public Object json() {
        Map map = new HashMap();
        map.put("username","zhb");
        map.put("password","123456");
        return map;
    }
}
